package oo_day03.oo_day03_HomeWork_01;

public class PolymorphicDemo {
    public static void main(String[] args) {
        Animal[] animals = new Animal[3];
        animals[0] = new Dog("小灰",3,"灰");
        animals[1] = new Chick("小黑",2,"黑");
        animals[2] = new Fish("小金",1,"金");
        for (int i = 0;i< animals.length;i++){
            System.out.println(animals[i].name);
            animals[i].drink();
            animals[i].eat();
            if (animals[i] instanceof Dog){
                Dog dog =(Dog)animals[i];
                dog.lookHome();
            }
            if (animals[i] instanceof Chick){
                Chick chick =(Chick)animals[i];
                chick.layege();
            }
            if (animals[i] instanceof Swim){
                Swim swim =(Swim) animals[i];
                swim.swim();
            }

        }System.out.println("------------");

    Master master = new Master();
    Dog dog = new Dog("小灰",2,"灰");
    Chick chick = new Chick("小黑",3,"黑");
    Fish fish = new Fish("小金",1,"金");
        master.feed(dog);
        master.feed(chick);
        master.feed(fish);
    }
}
